//
//  UIImageView+extensions.swift
//  YFSwiftWeibo
//
//  Created by tsaievan on 2017/9/8.
//  Copyright © 2017年 tsaievan. All rights reserved.
//

import SDWebImage

extension UIImageView {
    func yf_setImage(with urlString:String?, placeholderImage: UIImage?, isAvartar: Bool = false) {
        guard let urlString = urlString,
            let url = URL(string: urlString) else {
                image = placeholderImage
                return
        }
        sd_setImage(with: url, placeholderImage: placeholderImage, options: [], progress: nil) { (img, _, _, _) in
            if isAvartar {
                self.image = img?.yf_drawInRect(size: self.bounds.size)
            }
        }
    }
}
